<%@page contentType="text/html" pageEncoding="UTF-8" import="Funcionalidad.*,java.util.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<jsp:include page="../Apariencia/Cabecera.jsp"/>
<%

        if (session.getAttribute("loginuser") != null) {
            int rol = (Integer) session.getAttribute("loginrol");
            if (rol == 1) {
%>

<html>
    <%
                int id_galeria = Integer.parseInt(request.getParameter("id"));

                Galeria galery = Galerias.getGaleria(id_galeria);

                List<Fotografia> galeria = new ArrayList();
                try {
                    galeria = Fotografias.consultaGaleria(id_galeria);
                } catch (Exception ex) {
                    out.print(ex.getMessage());
                }

    %>
    <head>
        <title>FLOG - Administraci&oacute;n Galer&iacute;as</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <div id="administracion" class="admonGaleria">
        <body>
            <h1>ADMINISTRACI&Oacute;N Galer&iacute;as</h1>
            <table border='0'>
                <%int cont = 0;%>
                <tr>
                    <%
                Iterator it = galeria.iterator();
                while (it.hasNext()) {
                    Fotografia foto = (Fotografia) it.next();
                    if (cont < 4) {%>
                    <td>
                        <a href="<%= foto.getRuta()%>">&nbsp;&nbsp;<IMG  src="<%= foto.getRuta()%>" width="200"></a><br />
                        <a href="../Administracion/BorraFoto.jsp?id=<%= foto.getId_foto()%>&idgal=<%= foto.getId_galeria()%>">
                        <img src="../images/eliminar.png"class="x">Suprimir</a>
                    </td>
                    <% cont++;
                        } else {
                            cont = 1;%>
                </tr>
                <tr>
                <td>
                    <a href="<%= foto.getRuta()%>">&nbsp;&nbsp;<IMG  src="<%= foto.getRuta()%>" width="200" ></a><br />
                    <a href="../Administracion/BorraFoto.jsp?id=<%= foto.getId_foto()%>&idgal=<%= foto.getId_galeria()%>">
                    <img src="../images/eliminar.png" class="x">Suprimir</a>
                </td>


                <%}%>
                <td>&nbsp&nbsp&nbsp&nbsp</td>
                <%}%>
            </table>


        </body>
    </div>
</html>
<%
            } else {
                response.sendRedirect("../Apariencia/VistaPost.jsp");
            }
        }
%>

